Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pdfjs-dist/webpack causing errors with certain configs #11964

Merged
merged 1 commit into from
Jun 4, 2020

Conversation

aplum
Copy link
Contributor

@aplum aplum commented Jun 3, 2020

Using require.resolve("worker-loader") to check if worker-loader is installed causes webpack to include worker-loader in the output bundle (see docs), which is not the intended effect. Aside from increasing the bundle size unnecessarily, it also causes errors for webpack configs with targets that don't have node's built-in modules.

These errors can be fixed by configuring webpack externals to exclude worker-loader, but it's more difficult to figure out this solution than to figure out that worker-loader needs to be installed (even without this explicit error message).

To solve this, the explicit check for worker-loader has been removed. An alternative solution would be to use webpack's resolveWeak. Documentation has also been added in examples/webpack to help users.

The check was originally added in PR #11474. I've set up a minimal project to demonstrate the issue here.

Using `require.resolve("worker-loader")` to check if `worker-loader` is installed causes webpack to include `worker-loader` in the output bundle, which is not the intended effect. Aside from increasing the bundle size unnecessarily, it also causes errors for webpack configs with targets that don't have node's built-in modules.

These errors can be fixed by configuring webpack `externals` to exclude `worker-loader`, but it's more difficult to figure out this solution than to figure out that `worker-loader` needs to be installed (even without this explicit error message).

To solve this, the explicit check for `worker-loader` has been removed. An alternative solution would be to use webpack's `resolveWeak`. Documentation has also been added in `examples/webpack` to help users.
@timvandermeij timvandermeij merged commit 7aa1b2d into mozilla:master Jun 4, 2020
@timvandermeij
Copy link
Contributor

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants